home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / wsc4vb24 / finder.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-08-11  |  2.5 KB  |  95 lines

  1. VERSION 2.00
  2. Begin Form FINDER 
  3.    AutoRedraw      =   -1  'True
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "FINDER"
  6.    ClientHeight    =   5595
  7.    ClientLeft      =   2550
  8.    ClientTop       =   2730
  9.    ClientWidth     =   8565
  10.    FontBold        =   0   'False
  11.    FontItalic      =   0   'False
  12.    FontName        =   "Courier New"
  13.    FontSize        =   8.25
  14.    FontStrikethru  =   0   'False
  15.    FontUnderline   =   0   'False
  16.    Height          =   6285
  17.    Left            =   2490
  18.    LinkTopic       =   "Form1"
  19.    ScaleHeight     =   5595
  20.    ScaleWidth      =   8565
  21.    Top             =   2100
  22.    Width           =   8685
  23.    Begin Menu menuExit 
  24.       Caption         =   "Exit"
  25.    End
  26.    Begin Menu menuFinderModem 
  27.       Caption         =   "Find_Modem"
  28.    End
  29. ' FINDER.BAS
  30. Option Explicit
  31. Sub Form_Load ()
  32.     Call DisplayInit(FINDER)
  33. End Sub
  34. Sub menuExit_Click ()
  35.   End
  36. End Sub
  37. Sub menuFinderModem_Click ()
  38. Dim Port As Integer
  39. Dim Code As Integer
  40. 'examine COM1 through COM4 for modem
  41. For Port = COM1 To COM4
  42.   'reset the port
  43.   Call DisplayString(FINDER, "COM" + LTrim$(Str$(1 + Port)) + " ")
  44.   Code = SioReset(Port, 512, 512)
  45.   If Code < 0 Then
  46.     Call SayError(FINDER, Code)
  47.   Else
  48.     'we have hardware
  49.     Code = SioBaud(Port, Baud9600)
  50.     'set DTR & RTS
  51.     Code = SioDTR(Port, Asc("S"))
  52.     Code = SioRTS(Port, Asc("S"))
  53.     'look for DSR
  54.     If SioDSR(Port) Then
  55.       Call DisplayString(FINDER, " (DSR=1) ")
  56.       'got DSR, so lets send "AT"
  57.       Code = mioSendTo(Port, 100&, "!AT!")
  58.       Call RunDriver(Port)
  59.       'wait 2 seconds for OK
  60.       Code = mioWaitFor(Port, 2000&, "OK")
  61.       Call RunDriver(Port)
  62.       'get result
  63.       If mioResult(Port) Then
  64.         'found modem
  65.         Call DisplayLine(FINDER, " Modem is detected !")
  66.         Code = SioDone(Port)
  67.         Exit Sub
  68.       Else
  69.         'no response
  70.         Call DisplayLine(FINDER, " No response.")
  71.       End If
  72.     Else
  73.       Call DisplayLine(FINDER, " (DSR=0) ")
  74.     End If
  75.     'shut down port
  76.     Code = SioDone(Port)
  77.   End If
  78. Next Port
  79. Call DisplayLine(FINDER, "")
  80. Call DisplayLine(FINDER, "Cannot locate modem on COM1 through COM4")
  81. End Sub
  82. Sub RunDriver (ByVal Port As Integer)
  83. Dim Code As Integer
  84. While True
  85.   Code = mioDriver(Port)
  86.   If Code = MIO_IDLE Then
  87.     ' driver is done
  88.     Exit Sub
  89.   End If
  90.   If Code <> MIO_RUNNING Then
  91.     ' display character returned by driver
  92.     Call DisplayChar(FINDER, Code)
  93.   End If
  94. End Sub
  95.